package com.liwalo.utils;

import javax.servlet.http.HttpServletRequest;

import net.tanesha.recaptcha.ReCaptchaImpl;
import net.tanesha.recaptcha.ReCaptchaResponse;

public class CaptchaUtil {

	public static boolean validateCaptcha(HttpServletRequest request, String recaptcha_challenge_field, String recaptcha_response_field){
		String remoteAddr = request.getRemoteHost();
        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
        reCaptcha.setPrivateKey("6Le8meYSAAAAAG-ttSniRul5bolPxAvdqtaPMlSy");

        ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, recaptcha_challenge_field, recaptcha_response_field);
        
        return reCaptchaResponse.isValid();
	}

}
